#include "stdafx.h"
#include "TransformComponent.h"

namespace ZeEngine
{
	s64	TransformComponent::m_type = -1;
	s64	TransformComponent::m_index = -1;

	TransformComponent::TransformComponent(const Vector2D<float>& position, float rotation) :
		m_position(position), m_previousPosition(position),
		m_rotation(rotation), m_previousRotation(rotation),
		m_scale(Vector2D<float>(1, 1)), m_previousScale(m_scale),
		IComponent("TransformComponent", m_type, m_index)
	{

	}

	TransformComponent::TransformComponent() : TransformComponent(Vector2D<float>(), 0)
	{}

	TransformComponent::~TransformComponent()
	{
	}

	const Vector2D<float> TransformComponent::GetInterpolatedPosition(float interpolation) const
	{
		Vector2D<float> deltaVector = m_position - m_previousPosition;
		return (m_previousPosition + (deltaVector * interpolation));
	}

	const float TransformComponent::GetInterpolatedRotation(float interpolation) const
	{
		float deltaRotation = m_rotation - m_previousRotation;
		return (m_previousRotation + (deltaRotation * interpolation));
	}

	void TransformComponent::SetPosition(const Vector2D<float>& position)
	{
		if (position != m_position)
		{
			m_position = position;
		}
	}

	void TransformComponent::SetRotation(float rotation)
	{
		if (rotation != m_rotation)
		{
			m_rotation = rotation;
		}
	}

	void TransformComponent::SetScale(const Vector2D<float>& scale)
	{
		if (scale != m_scale)
		{
			m_scale = scale;

		}
	}
}
